package smat.intr

/**
 * @author Aram Altschudjian
 *
 */

import scala.collection.mutable.HashMap

object Matrix{
  val all = jmat.intr.Matrix.all
}

trait Matrix {
  def init(defaultValue: Any, sizes: List[Int])
  def init(defaultValue: Any, sizes: Int*)
  def data(matrix: Any)
  def data(): Any
  def ~(): Any
  def entries(): Int
  def indices(): List[Int]
  def indices(dimension: Int): List[Int]
  def <<(structure: Any)
  def apply(address: Int): Matrix
  def apply(address: String): Matrix
  def apply(address: List[Any]): Matrix
  def apply(address: Any*): Matrix
  def update(address: Any, entry: Any)
  def find(entry: Any): List[Int]
  def count(entry: Any): Int
  def setDim(dimensions: Int)
  def getDim(): Int
  def setSize(sizes: List[Int])
  def setSize(sizes: Int*)
  def size(): List[Int]
  def size(dimension: Int): Int
  def list(): List[Any]
  def unique(): List[Any]
  def isEmpty(): Boolean
  def ==(candidate: Matrix): Boolean
  def rows(): List[Int]
  def cols(): List[Int]
  def pages(): List[Int]
  def max(): Any
  def maxIndex(): Int
  def min(): Any
  def minIndex(): Int
  def sum(): Matrix
  def sumAll(): Any
  def +(matrix: Matrix): Matrix
  def +(number: Number): Matrix
  def -(matrix: Matrix): Matrix
  def -(number: Number): Matrix
  def *(matrix: Matrix): Matrix
  def *(number: Number): Matrix
  def /(matrix: Matrix): Matrix
  def /(number: Number): Matrix
  def log(): Matrix
  def -:(minuend: java.lang.Number): Matrix
  def extend(dimension: Int)
  def extend(dimension: Int, amount: Int)
  def delete(dimension: Int, address: Any)
  def delete(dimension: Int, address: Any*)
  def delete(address: List[Any])
  def delete(address: Any*)
  def setOrder(dimension: Int, order: List[Int])
  def setOrder(dimension: Int, order: Int*)
  def addDim(size: Int, index: Int)
  def setName(dimension: Int, index: Int, name: String)
  def setNames(dimension: Int, nameToIndexMap: HashMap[String, Int])
  def getNames(dimension: Int): HashMap[String, Int]
  def resolve(dimension: Int, address: String): Int
  def convert(address: Int): Array[Int]
  def convert(address: List[Any]): Int
  def convert(address: Any*): Int
  def getBackend(): jmat.intr.Matrix
  override def toString(): String
  
  protected def translateArray[srcT, destT](origin: Array[srcT]): Array[destT] = {
    val result = new Array[destT](origin.length)
    (0 to origin.length - 1).foreach(i => result(i) = origin(i).asInstanceOf[destT])
    return result
  }
  
  protected def arrayListFromList[srcT, destT](origin: List[srcT]): java.util.ArrayList[destT] = {
    val result = new java.util.ArrayList[destT](origin.length)
    origin.foreach(element => result.add(element.asInstanceOf[destT]))
    return result
  }
}
